{extend name='main'}

{block name="button"}

{if auth("admin/user/add")}
<button data-modal='{:url("add")}' data-title="添加用户" class='layui-btn layui-btn-sm layui-btn-primary'>添加用户</button>
{/if}

{if auth("admin/user/remove")}
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('admin/user/remove')}" data-confirm="确定要删除这些用户吗？" class='layui-btn layui-btn-sm layui-btn-primary'>删除用户</button>
{/if}

{/block}

{block name="content"}
<div class="think-box-shadow">

    <table class="layui-table" lay-skin="line">
        <caption class="margin-bottom-10 text-left">{include file='user/index_search'}</caption>
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
            </th>
            <th class='text-left nowrap' style="width:120px">用户名</th>
            <th class='text-left nowrap' style="width:120px">账号状态</th>
            <th class='text-left nowrap' style="width:180px">创建时间</th>
            <th class='text-left nowrap' style="width:150px">最后登录</th>
            <th class='text-left nowrap'></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
            <td class='text-left nowrap'>
                用户账号：{$vo.username|default=''}<br>
                联系手机：{$vo.phone|default='-'}
            </td>
            <td class='text-left nowrap'>
                登录次数：{$vo.login_num|default=0}<br>
                使用状态：{eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{else}<span class="color-green">使用中</span>{/eq}
            </td>
            <td class='text-left nowrap'>日期：{$vo.create_at|format_datetime|str_replace=' ','<br>时间：',###|raw}</td>
            <td class='text-left nowrap'>{if $vo.login_num>0}日期：{$vo.login_at|format_datetime|str_replace=' ','<br>时间：',###|raw}{else} -- {/if}</td>
            <td class='text-left nowrap'>

                {if auth("admin/user/auth")}
                <a class="layui-btn layui-btn-primary layui-btn-sm" data-title="用户授权" data-modal='{:url("auth")}?id={$vo.id}'>授 权</a>
                {/if}

                {if auth("admin/user/pass")}
                <a class="layui-btn layui-btn-normal layui-btn-sm" data-title="设置密码" data-modal='{:url("pass")}?id={$vo.id}'>密 码</a>
                {/if}

                {if auth("admin/user/edit")}
                <a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑用户" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
                {/if}

                {if $vo.status eq 1 and auth("admin/user/forbid")}
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('forbid')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('admin/user/forbid')}">禁 用</a>
                {elseif auth("admin/user/resume")}
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('resume')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('admin/user/resume')}">启 用</a>
                {/if}

                {if auth("admin/user/remove")}
                <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该用户吗？" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('admin/user/remove')}">删 除</a>
                {/if}

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>

{/block}
